package com.example.iotmanagerment26.service.impl;


import com.example.iotmanagerment26.mapper.CatMapper;
import com.example.iotmanagerment26.service.CatService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class CatSeviceImpl implements CatService {
    @Resource
    CatMapper catMapper;


    @Override
    public int quit() {
        for (Map.Entry<String, Object> entry : catMapper.get().entrySet()) {
            int n =((int)entry.getValue())-1;
            catMapper.set(n);
            return 1;
        }
        return -1;
    }

    @Override
    public int join() {
        for (Map.Entry<String, Object> entry : catMapper.get().entrySet()) {
            int n =((int)entry.getValue())+1;
            catMapper.set(n);
            return 1;
        }
        return -1;
    }

    @Override
    public int set(int num) {
        return catMapper.set(num);
    }

    @Override
    public Map<String, Object> get() {
        return catMapper.get();
    }
}
